window.onload=function(){
	$(".dealerManage").css("backgroundColor","#224247").siblings().css("backgroundColor","#365d62");
	var reg =/^[0-9]*$/;
	function iffn(){
		if($(".afterYear").val()<1000||$(".afterYear").val()>9999||!reg.test($(".afterYear").val())){
			alert("请输入有效起始年份。");
		}else if($(".afterMonth").val()>12||$(".afterMonth").val()<1||!reg.test($(".afterMonth").val())){
			alert("请输入有效起始起始月份。");
		}else if($(".afterMonth").val()==0){
			alert("请输入有效起始月份。");
		}else if($(".afterDate").val()>31||$(".afterDate").val()<1||!reg.test($(".afterDate").val())){
			alert("请输入有效起始日期。");
		}else if($(".afterDate").val()==0){
			alert("请输入有效起始日期。");
		}else if($(".beforeYear").val()<1000||$(".beforeYear").val()>9999||!reg.test($(".beforeYear").val())){
			alert("请输入有效截止年份。");
		}else if($(".beforeMonth").val()>12||$(".beforeMonth").val()<1||!reg.test($(".beforeMonth").val())){
			alert("请输入有效截止月份。");
		}else if($(".beforeMonth").val()==0){
			alert("请输入有效截止月份。");
		}else if($(".beforeDate").val()>31||$(".beforeDate").val()<1||!reg.test($(".beforeDate").val())){
			alert("请输入有效截止日期。");
		}else if($(".beforeDate").val()==0){
			alert("请输入有效截止日期。");
		}
	}
	//查询
	$(".dealerQueryBtn").click(function(){
		var after_date=$(".afterYear").val()+"-"+$(".afterMonth").val()+"-"+$(".afterDate").val();
		var before_date=$(".beforeYear").val()+"-"+$(".beforeMonth").val()+"-"+$(".beforeDate").val();
		var writeContent = $(".dealerBox").val();
		if($(".afterYear").val()==""&$(".afterMonth").val()==""&$(".afterDate").val()==""&$(".beforeYear").val()==""&$(".beforeMonth").val()==""&$(".beforeDate").val()==""&writeContent!=""){
			if(writeContent=="%"){
				alert("非法输入，请正确输入用户名！");
			}else{
				window.location.href='/admin/device/chargeRecords/dealer?dealer='+writeContent;
			}
		}else if($(".afterYear").val()!=""&$(".afterMonth").val()!=""&$(".afterDate").val()!=""&$(".beforeYear").val()!=""&$(".beforeMonth").val()!=""&$(".beforeDate").val()!=""&writeContent!=""){
			iffn();
			window.location.href='/admin/device/chargeRecords/dealer?dealer='+writeContent+'&after_date='+after_date+'&before_date='+before_date;
		}else if($(".afterYear").val()!=""&$(".afterMonth").val()!=""&$(".afterDate").val()!=""&$(".beforeYear").val()!=""&$(".beforeMonth").val()!=""&$(".beforeDate").val()!=""&writeContent==""){
			iffn();
			window.location.href='/admin/device/chargeRecords/dealer?after_date='+after_date+'&before_date='+before_date;
		}
	});
	//导出
	$(".exportBtn").click(function(){
		var after_date=$(".afterYear").val()+"-"+$(".afterMonth").val()+"-"+$(".afterDate").val();
		var before_date=$(".beforeYear").val()+"-"+$(".beforeMonth").val()+"-"+$(".beforeDate").val();
		var writeContent = $(".dealerBox").val();
		if($(".afterYear").val()==""&$(".afterMonth").val()==""&$(".afterDate").val()==""&$(".beforeYear").val()==""&$(".beforeMonth").val()==""&$(".beforeDate").val()==""&writeContent==""){
				window.location.href='/admin/device/chargeRecords/export';
		}else if($(".afterYear").val()==""&$(".afterMonth").val()==""&$(".afterDate").val()==""&$(".beforeYear").val()==""&$(".beforeMonth").val()==""&$(".beforeDate").val()==""&writeContent!=""){
			if(writeContent=="%"){
				alert("非法输入，请正确输入用户名！");
			}else{
				window.location.href='/admin/device/chargeRecords/export?dealer='+writeContent;
			}
		}else if($(".afterYear").val()!=""&$(".afterMonth").val()!=""&$(".afterDate").val()!=""&$(".beforeYear").val()!=""&$(".beforeMonth").val()!=""&$(".beforeDate").val()!=""&writeContent!=""){
			iffn();
			window.location.href='/admin/device/chargeRecords/export?dealer='+writeContent+'&after_date='+after_date+'&before_date='+before_date;
		}else if($(".afterYear").val()!=""&$(".afterMonth").val()!=""&$(".afterDate").val()!=""&$(".beforeYear").val()!=""&$(".beforeMonth").val()!=""&$(".beforeDate").val()!=""&writeContent==""){
			iffn();
			window.location.href='/admin/device/chargeRecords/export?after_date='+after_date+'&before_date='+before_date;
		}
	});
}
	